﻿// Copyright (c) Vitaly Kamiansky. All rights reserved. 
// See License.txt in the project root.

using System;

namespace Property.Reloaders
{
    public partial class ConditionReloaderDecoratorPrototype<T>
        : ReloaderDecoratorPrototype<T>
    {
        public ConditionReloaderDecoratorPrototype(IReloaderPrototype<T> compositionBasePrototype, Func<bool> condition)
            : base(compositionBasePrototype)
        {
            _Condition = condition;
        }

        //=//

        private readonly Func<bool> _Condition;

        public override IReloader Create(Func<T> getValue, Action<T> applyValue, Action<bool> applyStatus)
        {
            return new DecoratorInstance(_CompositionBasePrototype, getValue, applyValue, applyStatus, _Condition);
        }
    }
}
